﻿using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using FTC.SharePoint.Evolution.Core;
using System.Collections.Generic;
using System.Text;

namespace FTC.SharePoint.Evolution.Layouts
{
    /// <summary>
    /// TODO: add multilanguage support (resx files)
    /// </summary>
    public partial class AppliedEvos : LayoutsPageBase
    {
        public string Debug { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (SPContext.Current.Web.AllProperties[SPProviderConstants.PROPERTY_NAME] != null)
            {
                StringBuilder str = new StringBuilder();
                List<long> appliedToWeb = SPProvider.DeserializeStringToLongList(SPContext.Current.Web.AllProperties[SPProviderConstants.PROPERTY_NAME].ToString());
                if (appliedToWeb != null)
                {
                    str.Append("<ul style=\"margin: 20px\">");
                    foreach (long l in appliedToWeb)
                    {
                        str.AppendFormat("<li> evo version = {0} <a href=\"\">discard</a> </li>", l);
                    }
                    str.Append("</ul>");
                    Debug = str.ToString();
                }
                else
                {
                    Debug = "schema was downgrade to base";
                }
            }
            else
            {
                Debug = "Empty";
            }
        }
    }
}
